<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="p" uri="/WEB-INF/tld/page.tld" %>
<script type="text/javascript">

	$(function() {
		$("#order_date1").datepicker({dateFormat: 'yy-mm-dd'});
		$("#order_date2").datepicker({dateFormat: 'yy-mm-dd'});
	});
	
	function query() {
		var start = $("#order_date1").val();
		start.replaceAll("-", "/");
		var end = $("#order_date2").val();
		end.replaceAll("-", "/");
		var date1 = new Date(start);
		var date2 = new Date(end);
		if(date1!=""&&date2!=""&&date1.getTime()>date2.getTime()) $.jqalert("起始日期不能大于截止日期！！");
		else {
			$.ajax({
				url:"${basePath}/trade/cancel_list.htm",
				type:"post",
				data:$("#cancel_order_form").serialize(),
				dataType:"html",
				success:function(data) {
					$(".main").html(data);
				}
			});
		}
	}
	
	function reset() {
		$(":input", "#cancel_order_form").not(":hidden").val("");
		$("#cancel_order_form").find("select").val("");
	}
	
	function detail(oid, cid) {
		$(".main").load("${basePath}/trade/cancel_detail.htm", {orderId:oid, customerId:cid});
	}
	
	function turnpage(page) {
		$("#cancel_order_form").children().first().val(page);
		query();
	}
</script>

 <div class="cont">
    <h2 class="title">查询条件：</h2>
    <div class="ui_sel clearfix">
    <form id="cancel_order_form" method="post">
    <input type="hidden" name="pageNo">
    	<div class="label_box fl">
            <span class="sel_label fl">交易类型：</span>
            <select name="type">
            	<option value="">--全部--</option>
            	<c:forEach items="${tradeTypes }" var="tradeType">
            		<option value="${tradeType.code }"
            			<c:if test="${query.type eq tradeType.code }">
		               		selected="selected"
		               	</c:if>
            		>${tradeType.desc }</option>
            	</c:forEach>
            </select>
        </div>
        <div class="label_box fl">
            <span class="sel_label fl">交易日期：</span>
            <input id="order_date1" type="text" readonly="readonly" name="order_date1" value="${query.order_date1 }">
        </div>
        <div class="label_box fl">
            <span class="sel_label fl">至</span>
            <input id="order_date2" type="text" readonly="readonly" name="order_date2" value="${query.order_date2 }">
        </div>
        <div class="label_box fl">
            <span class="sel_label fl">交易号：</span>
            <input type="text" class="text_input fl" name="order_no" value="${query.order_no }">
        </div>
        <div class="label_box fl">
            <span class="sel_label fl">所属门店：</span>
            <select name="store_name">
                <option value="">--全部--</option>
                <c:forEach items="${login_user.stores }" var="store">
                	<option value="${store.store_name }"
                		<c:if test="${query.store_name eq store.store_name }">
	                		selected="selected"
	                	</c:if>
                	>${store.store_name }</option>
                </c:forEach>
            </select>
        </div>
        </form>
        <a href="javascript:;" class="green_btn btn fl" onclick="query();">确定</a>
        <a href="javascript:;" class="yellow_btn btn fl" onclick="reset();">重置</a>
    </div>
    <div class="ui">
        <table class="table_list">
            <tr class="">
              <th class="">序号</th>
              <th>交易号</th>
              <th>交易类型</th>
              <th class="">交易日期</th>
              <th class="">交易总金额（元）</th>
              <th class="">客户姓名</th>
              <th class="">客户电话</th>
              <th class="">所属门店</th>
              <th class="">卡号</th>
              <th class="">操作</th>
            </tr>
            <c:forEach items="${orders }" var="order">
            <tr class="">
              <td class="">${order.index }</td>
              <td class="">${order.order_no }</td>
              <td class="">${order.order_status_display }</td>
              <td class="">${order.order_date_display }</td>
              <td class="">${order.pay_amount }</td>
              <td class="">${order.name }</td>
              <td class="">${order.telphone }</td>
              <td class="">${order.store_name }</td>
              <td class="">${order.serial_no }</td>
              <td class="">
              <c:if test="${order.order_status eq 0 }">
              	<a href="javascript:;" target="_blank" onclick='detail("${order.id}","${order.customer_id }")'>查看并撤销</a>
              </c:if>
              </td>
            </tr>
            </c:forEach>
        </table>
    </div>
</div>
<p:page map="${page }"></p:page>